﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ZHello.Algorithm
{
    /// <summary>
    /// 常见算法
    /// </summary>
    public class CommonAl
    {
        /// <summary>
        /// 计算斐波那契数列
        /// 0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987...
        /// </summary>
        /// <param name="x">输出第几个数字，从0开始</param>
        /// <returns></returns>
        public static int CalcFibonacci(int x)
        {
            if (x == 0)
                return 0;
            if (x == 1)
                return 1;
            x--;
            return CalcFibonacci(x) + CalcFibonacci(x - 1);
        }
    }
}
